package net.digitalartwork.ui{
	//import flash.filters.DropShadowFilter;
	//import fl.transitions.*;
	//import fl.transitions.easing.*;
	import flash.display.Stage;
	import flash.display.MovieClip;
	import flash.events.*;
	import flash.display.*;
	import flash.text.*;
	import net.digitalartwork.text.*;
	import gs.TweenFilterLite;
	import fl.motion.easing.*

	

	public class FeedbackWindow extends Sprite{
		var windowText:TextMaker = new TextMaker;
		var theWindow:Sprite = new Sprite();
		var bg:SunDraw;
		var currentText:String;
		var progressBarBG:SunDraw;
		var progressBar:SunDraw;
		
		public function FeedbackWindow(theText:String, myFont:String ) {
			
			theWindow.name = "window";
			addChild(theWindow);
			theWindow.x = -60;
			theWindow.y = -25;
			
			bg = new SunDraw({shapeType:"roundedrectangle", shapeRadius:15, shapeWidth:120, shapeHeight:50, hexFill:0x000000, shapeFillAlpha:.80});
			progressBarBG = new SunDraw({shapeType:"rectangle", shapeWidth:100, shapeHeight:10, hexFill:0xFFFFFF, shapeFillAlpha:.25});
			progressBar = new SunDraw({shapeType:"rectangle", shapeWidth:10, shapeHeight:10, hexFill:0xFFFFFF, shapeFillAlpha:.5});
			
			//var toolText:TextMaker = new TextMaker;
			windowText.returnText(100, 20, 200, 20);
			windowText.selectable=false;
			windowText.autoSize = "left";
			windowText.wordWrap = true;
			windowText.antiAliasType = AntiAliasType.ADVANCED;
			theWindow.addChild(windowText);
			
			
			windowText.x = 10;
			windowText.y = 10;
			
			var format:TextFormat = new TextFormat();
			format.font = myFont;
			format.color = 0xFFFFFF;
			format.size = 11;
			//format.underline = true;
			windowText.defaultTextFormat = format;
			windowText.text = theText;
			windowText.width = 100;
			windowText.height = 50;
			
			
			bg.name = "background";
			theWindow.addChildAt(bg, 0);
			theWindow.addChild(progressBarBG);
			theWindow.addChild(progressBar);
			
			progressBarBG.y = bg.height - progressBarBG.height - 10;
			progressBar.y = progressBarBG.y;
			progressBar.x = 10;
			progressBarBG.x = 10;
			
			
			theWindow.visible = false;
		}

		
		public function setProgressBarWidth(w:Number, t:String):void {
			progressBar.visible=true;
			progressBarBG.visible=true;
			windowText.text = t;
			progressBar.width = w;
			
		}

		public function showWindow():void {
			theWindow.y = -50;
			windowText.visible=true;
			theWindow.visible=true;
			//TweenFilterLite.to(theWindow, .5, {scaleX:1, scaleY:1, alpha:1, ease:Back.easeOut});
			TweenFilterLite.to(theWindow, .5, {y:-25, alpha:1, ease:Back.easeOut});
		}
		public function hideWindow():void {
			//TweenFilterLite.to(theWindow, .5, {scaleX:.1, scaleY:.1, alpha:0, onComplete:setWindowInvisible, ease:Back.easeOut});
			windowText.visible=false;
			TweenFilterLite.to(theWindow, .5, {y:25, alpha:0, onComplete:setWindowInvisible, ease:Back.easeOut});
			
		}
		private function setWindowInvisible():void {
			theWindow.visible=false;
		}
		public function setWindowText(t:String):void {
			progressBar.visible=false;
			progressBarBG.visible=false;
			windowText.text = t;
		}
	}
}




